package string;

public class ReplaceAllSToAvoidConsecutiveRepeatingCharacters1576 {
    public String modifyString(String s) {
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if(chars[i]=='?'){
                char left = '?';
                char right = '?';
                if(i-1>=0){
                    left = chars[i-1];
                }
                if(i+1<chars.length){
                    right = chars[i+1];
                }
                char replace = '?';
                for (char j = 'a'; j <= 'z'; j++) {
                    if(j!=left&&j!=right){
                        replace=j;
                        break;
                    }
                }
                chars[i] = replace;
            }
        }
        return String.valueOf(chars);
    }
}
